package com.cis.hpspc;
    import android.app.Activity;  
    import android.content.SharedPreferences;  
    import android.os.Bundle;  
    import android.preference.PreferenceManager;  
    import android.widget.TextView;  
    public class MainActivity extends Activity {  
        /** Called when the activity is first created. */  
        @Override  
        public void onCreate(Bundle savedInstanceState) {  
            super.onCreate(savedInstanceState);  
            setContentView(R.layout.activity_main);  
              
            SharedPreferences mSharedPreferences = getSharedPreferences("TestSharedPreferences", 0);  
    //        SharedPreferences mSharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);  
              
            int counter = mSharedPreferences.getInt("counter", 0);  
              
            TextView mTextView = (TextView)findViewById(R.id.textview);  
            mTextView.setText("This app has been started " + counter + " times.");  
              
            SharedPreferences.Editor mEditor = mSharedPreferences.edit();  
            mEditor.putInt("counter", ++counter);  
            mEditor.commit();  
              
        }  
    }  
